package com.szewec.ps.ui.road.facilities.investigation.task.modern.urban.transit;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.szewec.ps.R;
import com.szewec.ps.base.BaseActivity;
import com.szewec.ps.base.BaseMediaPickerActivity;
import com.szewec.ps.base.Constants;
import com.szewec.ps.base.Enums;
import com.szewec.ps.base.FileUpload;
import com.szewec.ps.databinding.ActivityRoadModernUrbanTransitBinding;
import com.szewec.ps.model.PresentValue;
import com.szewec.ps.model.ViewModeValue;
import com.szewec.ps.model.road.facilities.investigation.task.RoadFacilitiesInvestigationTask;
import com.szewec.ps.model.road.facilities.investigation.task.RoadFacilitiesInvestigationTaskDTO;
import com.szewec.ps.model.road.facilities.investigation.task.RoadModernUrbanTransit;
import com.szewec.ps.model.selectmappoint.SelectedPoint;
import com.szewec.ps.myview.InputItem;
import com.szewec.ps.myview.LocationEdit;
import com.szewec.ps.myview.indicator.IndicatorViewPager;
import com.szewec.ps.myview.indicator.OnTransitionTextListener;
import com.szewec.ps.myview.indicator.slidebar.DrawableBar;
import com.szewec.ps.util.CommonUtils;
import com.szewec.ps.util.RollUtil;
import com.szewec.ps.util.StringUtils;
import com.szewec.ps.util.TextViewUtil;
import com.szewec.ps.util.imagepicker.adapter.CustomPickerAdapterShowAndEdit;
import com.szewec.ps.util.imagepicker.data.MediaFile;

import org.apache.commons.collections4.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.ButterKnife;

public class RoadModernUrbanTransitActivity extends BaseMediaPickerActivity {
    private ActivityRoadModernUrbanTransitBinding binding;
    private IndicatorViewPager indicatorViewPager;
    private MyAdapter myAdapter;
    /********字典start***********/
    // 运营模式
    private ArrayList<String> operationModeDict = new ArrayList<>();
    // 线路模式
    private ArrayList<String> lineModeDict = new ArrayList<>();
    // 车站形式
    private ArrayList<String> stationFormDict = new ArrayList<>();
    /********字典end***********/

    DrawableBar drawableBar;
    // 路段设施调查任务DTO
    private RoadFacilitiesInvestigationTaskDTO.RoadFacilitiesTaskDTO roadFacilitiesTaskDTO;
    // 标签页
    private String[] versions = {"轻轨", "BRT", "有轨电车", "照片"};
    // 轻轨
    private RoadModernUrbanTransit roadModernUrbanTransitLightRail = new RoadModernUrbanTransit();
    // BRT
    private RoadModernUrbanTransit roadModernUrbanTransitBRT = new RoadModernUrbanTransit();
    // 有轨电车
    private RoadModernUrbanTransit roadModernUrbanTransitTram = new RoadModernUrbanTransit();
    private Point screenPoint;
    private List<Integer> textWidths = new ArrayList<>();
    // 用于区分新增还是修改还是详情展示
    private String ModeFlag_Add_Edit_View;
    private ViewModeValue viewModeValue;

    // 照片上传数组
    private List<String> photoSketchUploadIdArr = new ArrayList<>();
    // 照片文件数组
    private ArrayList<MediaFile> photoSketchFileArr = new ArrayList<>();
    // 图片适配器
    private CustomPickerAdapterShowAndEdit photoSketchAdapter;
    // 移除的图片ID数组
    private List<String> deletePhotoIdArr = new ArrayList<>();

    /********坐标start***********/
    private SelectedPoint centerPoint;

    private SelectedPoint startLightRailPoint;
    private SelectedPoint endLightRailPoint;
    private SelectedPoint startBRTPoint;
    private SelectedPoint endBRTPoint;
    private SelectedPoint startTramPoint;
    private SelectedPoint endTramPoint;
    private static final int START_LIGHT_RAIL = 1;
    private static final int END_LIGHT_RAIL = 2;
    private static final int START_BRT = 3;
    private static final int END_BRT = 4;
    private static final int START_TRAM = 5;
    private static final int END_TRAM = 6;

    /********坐标end***********/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_road_modern_urban_transit);
        ButterKnife.bind(this);
        initData();
        initTitleBar();
        initRecycleView();
        indicatorViewPager.notifyDataSetChanged();
    }

    private void initData() {
        // 初始化字典
        operationModeDict = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.operationMode)));
        lineModeDict = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.lineMode)));
        stationFormDict = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.stationForm)));

        // 获取intent中的数据
        PresentValue<RoadFacilitiesInvestigationTaskDTO.RoadFacilitiesTaskDTO> presentValue =
                (PresentValue<RoadFacilitiesInvestigationTaskDTO.RoadFacilitiesTaskDTO>) getIntent().getSerializableExtra(Constants.EXTRA_KEY.ROAD_INVESTIGATION_TASK_DTO);
        //获取是新增还是修改还是详情展示
        assert presentValue != null;
        ModeFlag_Add_Edit_View = presentValue.getFlag();
        roadFacilitiesTaskDTO = presentValue.getT();
        Log.i("现代轨道交通getData", JSONObject.toJSONString(roadFacilitiesTaskDTO));

        // 获取 路段设施调查任务 传过来的数据
        roadModernUrbanTransitLightRail = roadFacilitiesTaskDTO.getRoadModernUrbanTransitLightRail() == null
                ? new RoadModernUrbanTransit() : roadFacilitiesTaskDTO.getRoadModernUrbanTransitLightRail();
        roadModernUrbanTransitBRT = roadFacilitiesTaskDTO.getRoadModernUrbanTransitBRT() == null
                ? new RoadModernUrbanTransit() : roadFacilitiesTaskDTO.getRoadModernUrbanTransitBRT();
        roadModernUrbanTransitTram = roadFacilitiesTaskDTO.getRoadModernUrbanTransitTram() == null
                ? new RoadModernUrbanTransit() : roadFacilitiesTaskDTO.getRoadModernUrbanTransitTram();
    }

    private void initTitleBar() {
        ViewModeValue viewModeValue = new ViewModeValue(this, ModeFlag_Add_Edit_View, binding.titleBar, binding.llContainer);

        //设置导航栏右侧按钮
        if (Constants.PRESENT_VALUE_FLAG.VIEW.equals(ModeFlag_Add_Edit_View)) {
            CommonUtils.setViewMode(viewModeValue, this::finish, this::callMoreMenu);
        } else if (Constants.PRESENT_VALUE_FLAG.ADD.equals(ModeFlag_Add_Edit_View)
                || Constants.PRESENT_VALUE_FLAG.EDIT.equals(ModeFlag_Add_Edit_View)) {
            CommonUtils.setViewMode(viewModeValue, this::returnCheck, this::appendOrModifyData);
        }
    }

    private void appendOrModifyData() {
        roadFacilitiesTaskDTO.setRoadModernUrbanTransitLightRail(myAdapter.getData(0));
        roadFacilitiesTaskDTO.setRoadModernUrbanTransitBRT(myAdapter.getData(1));
        roadFacilitiesTaskDTO.setRoadModernUrbanTransitTram(myAdapter.getData(2));
        // 保存附件ID
        roadFacilitiesTaskDTO.setRoadModernUrbanTransitFileIds(photoSketchUploadIdArr);
        roadFacilitiesTaskDTO.setRemoveRoadModernUrbanTransitFileIds(deletePhotoIdArr);
        Log.i("现代轨道交通save", JSONObject.toJSONString(roadFacilitiesTaskDTO));
        Intent intent = new Intent();
        PresentValue<RoadFacilitiesInvestigationTaskDTO.RoadFacilitiesTaskDTO> presentValue = new PresentValue<>(ModeFlag_Add_Edit_View, roadFacilitiesTaskDTO);
        intent.putExtra(Constants.EXTRA_KEY.ROAD_INVESTIGATION_TASK_DTO, presentValue);
        setResult(Constants.RESULT_CODE.NEED_REFRESH, intent);
        finish();
    }

    private void returnCheck() {
        finish();
    }

    private void callMoreMenu() {
        CommonUtils.showMoreMenu(this, binding.titleBar.getRightLayout(), this::linkToEditActivity, this::deleteData);
    }

    private void deleteData() {

    }

    private void linkToEditActivity() {
    }

    private void initRecycleView() {
        float unSelectSize = 15; //未被选中的标题的字体大小
        float selectSize = unSelectSize * 1.07f; //选中后的标题的字体大小
        binding.moretabIndicator.setOnTransitionListener(new OnTransitionTextListener().setColor(0xFF333333, 0xFF949AA6).setSize(selectSize, unSelectSize));

        WindowManager winManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        screenPoint = new Point();
        winManager.getDefaultDisplay().getSize(screenPoint);
        drawableBar = new DrawableBar(RoadModernUrbanTransitActivity.this, getDrawable(R.drawable.silde_block));

        binding.moretabViewPager.setOffscreenPageLimit(versions.length - 1);
        indicatorViewPager = new IndicatorViewPager(binding.moretabIndicator, binding.moretabViewPager);
        myAdapter = new MyAdapter();
        indicatorViewPager.setAdapter(myAdapter);
    }

    private int getTextWidth(TextView textView) {
        if (textView == null) {
            return 0;
        }
        Rect bounds = new Rect();
        String text = textView.getText().toString();
        Paint paint = textView.getPaint();
        paint.getTextBounds(text, 0, text.length(), bounds);
        return bounds.left + bounds.width();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            //拍照返回，或者视频录制返回
            if (isAdapterImagePickerResult(requestCode, photoSketchAdapter)) {
                ArrayList<MediaFile> mediaFileList = getMediaFileListWhenOnActivityResult(requestCode, data, photoSketchAdapter);
                saveFileAndRefreshAdapter(mediaFileList, photoSketchUploadIdArr, photoSketchAdapter,
                        FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_MODERN_URBAN_TRANSIT_FILE_BIZ_TYPE);
            }
        }

        //选择了坐标
        if (resultCode == Constants.RESULT_CODE.SELECTED_POINT && data != null) {
            Bundle presentValue = data.getExtras();
            centerPoint = (SelectedPoint) presentValue.getSerializable(Constants.EXTRA_KEY.MAP_CENTER_POINT);
            if (centerPoint == null) {
                return;
            }
            // 将获取到的坐标赋给相对应的对象
            switch (requestCode) {
                // 轻轨-起点
                case START_LIGHT_RAIL:
                    startLightRailPoint = centerPoint;
                    break;
                // 轻轨-终点
                case END_LIGHT_RAIL:
                    endLightRailPoint = centerPoint;
                    break;
                // BRT-起点
                case START_BRT:
                    startBRTPoint = centerPoint;
                    break;
                // BRT-终点
                case END_BRT:
                    endBRTPoint = centerPoint;
                    break;
                // 有轨电车-起点
                case START_TRAM:
                    startTramPoint = centerPoint;
                    break;
                // 有轨电车-终点
                case END_TRAM:
                    endTramPoint = centerPoint;
                    break;
            }
        }
    }

    public class MyAdapter extends IndicatorViewPager.IndicatorViewPagerAdapter {

        @Override
        public int getCount() {
            return versions.length;
        }

        @Override
        public View getViewForTab(int position, View convertView, ViewGroup container) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.tab_top, container, false);
            }
            TextView textView = (TextView) convertView;
            textView.setText(versions[position]);
//            int padding = DisplayUtil.dipToPix(getApplicationContext(), 8);
            //因为wrap的布局 字体大小变化会导致textView大小变化产生抖动，这里通过设置textView宽度就避免抖动现象
            //1.3f是根据上面字体大小变化的倍数1.3f设置
            textView.setWidth(screenPoint.x / 4);
            textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            int textWidth = getTextWidth(textView);
            textWidths.add(textWidth);
            if (position == 0) {
//            drawableBar.setWH(getTextWidth(textView), 3);
                drawableBar.setWidth(textWidth);
                binding.moretabIndicator.setScrollBar(drawableBar);
            }
            return textView;
        }

        private List<View> views = new ArrayList<>();

        @Override
        public View getViewForPage(int position, View convertView, ViewGroup container) {
            // 总共四个标签页，第四个标签页是照片，所以不用初始化
            if (convertView == null) {
                if (position == 3) {
                    convertView = getLayoutInflater().inflate(R.layout.activity_road_modern_urban_transit_photo, container, false);
                } else {
                    convertView = getLayoutInflater().inflate(R.layout.activity_road_modern_urban_transit_type, container, false);
                }
            }
            switch (position) {
                case 0:
                    // 轻轨 需要隐藏运营模式选项
                    View operationMode = convertView.findViewById(R.id.operationMode);
                    operationMode.setVisibility(View.GONE);
                    setData(position, convertView, roadModernUrbanTransitLightRail);
                    initSelect(convertView);
                    break;
                case 1:
                    setData(position, convertView, roadModernUrbanTransitBRT);
                    initSelect(convertView);
                    break;
                case 2:
                    setData(position, convertView, roadModernUrbanTransitTram);
                    initSelect(convertView);
                    break;
                case 3:
                    setData(position, convertView, null);
                    break;
            }
            views.add(convertView);
            return convertView;
        }


        /**
         * 获取指定Tab页签的数据
         *
         * @param position 第几个页签
         */
        public RoadModernUrbanTransit getData(int position) {
            RoadModernUrbanTransit roadModernUrbanTransit = new RoadModernUrbanTransit();
            View view = views.get(position);
            // 起点
            LocationEdit startingPoint = view.findViewById(R.id.startingPoint);
            // 终点
            LocationEdit endPoint = view.findViewById(R.id.endPoint);
            // 运营模式
            InputItem operationMode = view.findViewById(R.id.operationMode);
            // 线路模式
            InputItem lineMode = view.findViewById(R.id.lineMode);
            // 线路数量
            InputItem numberOfLines = view.findViewById(R.id.numberOfLines);
            // 车道宽度
            InputItem laneWidth = view.findViewById(R.id.laneWidth);
            // 车道名称
            InputItem stationName = view.findViewById(R.id.stationName);
            // 车道形式
            InputItem stationForm = view.findViewById(R.id.stationForm);
            // 停靠线路
            InputItem stopLine = view.findViewById(R.id.stopLine);

            // 获取坐标
            String startPointStr = null;
            String endPointStr = null;
            switch (position) {
                case 0:
                    startPointStr = startLightRailPoint == null ? null : JSONObject.toJSONString(startLightRailPoint);
                    endPointStr = endLightRailPoint == null ? null : JSONObject.toJSONString(endLightRailPoint);
                    break;
                case 1:
                    startPointStr = startBRTPoint == null ? null : JSONObject.toJSONString(startBRTPoint);
                    endPointStr = endBRTPoint == null ? null : JSONObject.toJSONString(endBRTPoint);
                    break;
                case 2:
                    startPointStr = startTramPoint == null ? null : JSONObject.toJSONString(startTramPoint);
                    endPointStr = endTramPoint == null ? null : JSONObject.toJSONString(endTramPoint);
                    break;
            }
            // 保存坐标
            if (StringUtils.isNotEmpty(startPointStr)) {
                roadModernUrbanTransit.setStartingPoint(startPointStr);
            }
            if (StringUtils.isNotEmpty(endPointStr)) {
                roadModernUrbanTransit.setEndPoint(endPointStr);
            }

            // 添加路段调查任务ID
            RoadFacilitiesInvestigationTask facilitiesInvestigationTask = roadFacilitiesTaskDTO.getFacilitiesInvestigationTask();
            if (facilitiesInvestigationTask != null && StringUtils.isNotEmpty(facilitiesInvestigationTask.getId())) {
                roadModernUrbanTransit.setRoadInvestigationTaskId(facilitiesInvestigationTask.getId());
            }

            // 设置交通类型，交通类型 = 当前页签编号 + 1
            roadModernUrbanTransit.setTrafficType(position + 1);

            // 若选择“轻轨”，运营模式只能选择独立路权
            if (StringUtils.isNotEmpty(operationMode.getStringValue())) {
                roadModernUrbanTransit.setOperationMode(position == 0 ? 1 : Enums.OperationModeEnum.getKeyByValue(operationMode.getStringValue()));
            }
            if (StringUtils.isNotEmpty(lineMode.getStringValue())) {
                roadModernUrbanTransit.setLineMode(Enums.LineModeEnum.getKeyByValue(lineMode.getStringValue()));
            }
            if (numberOfLines.getIntValue() != null) {
                roadModernUrbanTransit.setNumberOfLines(numberOfLines.getIntValue());
            }
            if (laneWidth.getBigDecimalValue() != null) {
                roadModernUrbanTransit.setLaneWidth(laneWidth.getBigDecimalValue());
            }
            if (StringUtils.isNotEmpty(stationName.getStringValue())) {
                roadModernUrbanTransit.setStationName(stationName.getStringValue());
            }
            if (StringUtils.isNotEmpty(stationForm.getStringValue())) {
                roadModernUrbanTransit.setStationForm(Enums.StationFormEnum.getKeyByValue(stationForm.getStringValue()));
            }
            if (StringUtils.isNotEmpty(stopLine.getStringValue())) {
                roadModernUrbanTransit.setStopLine(stopLine.getStringValue());
            }

            return roadModernUrbanTransit;
        }

        /**
         * 填充指定Tab页签数据
         */
        private void setData(int position, View view, RoadModernUrbanTransit roadModernUrbanTransit) {
            // 起点
            LocationEdit startingPoint = view.findViewById(R.id.startingPoint);
            // 终点
            LocationEdit endPoint = view.findViewById(R.id.endPoint);
            // 运营模式
            InputItem operationMode = view.findViewById(R.id.operationMode);
            // 线路模式
            InputItem lineMode = view.findViewById(R.id.lineMode);
            // 线路数量
            InputItem numberOfLines = view.findViewById(R.id.numberOfLines);
            // 车道宽度
            InputItem laneWidth = view.findViewById(R.id.laneWidth);
            // 车道名称
            InputItem stationName = view.findViewById(R.id.stationName);
            // 车道形式
            InputItem stationForm = view.findViewById(R.id.stationForm);
            // 停靠线路
            InputItem stopLine = view.findViewById(R.id.stopLine);

            // 初始化坐标request
            switch (position) {
                case 0:
                    startingPoint.setRequestCode(START_LIGHT_RAIL);
                    endPoint.setRequestCode(END_LIGHT_RAIL);
                    break;
                case 1:
                    startingPoint.setRequestCode(START_BRT);
                    endPoint.setRequestCode(END_BRT);
                    break;
                case 2:
                    startingPoint.setRequestCode(START_TRAM);
                    endPoint.setRequestCode(END_TRAM);
                    break;
                case 3:
                    // 初始化照片适配器
                    photoSketchAdapter = initTypeMediaRecyclerView(photoSketchUploadIdArr, photoSketchFileArr,
                            view.findViewById(R.id.photo_sketch_sketch_RV), true, false, true, deletePhotoIdArr);
                    // 设置照片
                    initViewFile();
                    break;
            }

            // 第三个标签页为图片 无需填充数据
            if (roadModernUrbanTransit == null || position == 3) {
                return;
            }
            // 将坐标回显
            String startPointStr = roadModernUrbanTransit.getStartingPoint();
            String endPointStr = roadModernUrbanTransit.getEndPoint();
            SelectedPoint startSelectPoint = JSONObject.parseObject(startPointStr, SelectedPoint.class);
            SelectedPoint endSelectPoint = JSONObject.parseObject(endPointStr, SelectedPoint.class);
            startSelectPoint = startSelectPoint == null ? new SelectedPoint() : startSelectPoint;
            endSelectPoint = endSelectPoint == null ? new SelectedPoint() : endSelectPoint;
            startingPoint.setValue(startSelectPoint.getxCoordinate(), startSelectPoint.getyCoordinate());
            endPoint.setValue(endSelectPoint.getxCoordinate(), endSelectPoint.getyCoordinate());

            operationMode.setValue(Enums.OperationModeEnum.getValueByKey(roadModernUrbanTransit.getOperationMode()));
            lineMode.setValue(Enums.LineModeEnum.getValueByKey(roadModernUrbanTransit.getLineMode()));
            numberOfLines.setValue(roadModernUrbanTransit.getNumberOfLines());
            laneWidth.setValue(roadModernUrbanTransit.getLaneWidth());
            stationName.setValue(roadModernUrbanTransit.getStationName());
            stationForm.setValue(Enums.StationFormEnum.getValueByKey(roadModernUrbanTransit.getStationForm()));
            stopLine.setValue(roadModernUrbanTransit.getStopLine());
        }

        // 设置照片
        private void initViewFile() {
            RoadFacilitiesInvestigationTask facilitiesInvestigationTask = roadFacilitiesTaskDTO.getFacilitiesInvestigationTask();

            // 先根据fileId查询附件数据
            if (!CollectionUtils.isEmpty(roadFacilitiesTaskDTO.getRoadModernUrbanTransitFileIds())) {
                requestFilesByIds(roadFacilitiesTaskDTO.getRoadModernUrbanTransitFileIds(), this::initAdapterData);
            }
            // 根据业务ID查询附件信息
            else if (facilitiesInvestigationTask != null && StringUtils.isNotEmpty(facilitiesInvestigationTask.getId())) {
                requestFiles(FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_MODERN_URBAN_TRANSIT_FILE_BIZ_TYPE, facilitiesInvestigationTask.getId(), this::initAdapterData);
            }
        }

        // 往照片适配器里面设置图片显示
        private void initAdapterData(List<MediaFile> mediaFileList) {
            if (CollectionUtils.isEmpty(mediaFileList)) {
                return;
            }
            photoSketchUploadIdArr.clear();
            photoSketchFileArr.clear();
            // 添加到文件数组
            photoSketchFileArr.addAll(mediaFileList);
            for (MediaFile mediaFile : photoSketchFileArr) {
                photoSketchUploadIdArr.add(mediaFile.getId());
            }
            // 设置适配器数据源
            photoSketchAdapter.setmMediaFileList(mediaFileList);
        }

        /**
         * 初始化选项
         */
        private void initSelect(View convertView) {
            // 运营模式
            InputItem operationMode = convertView.findViewById(R.id.operationMode);
            //隐藏系统软键盘
            TextViewUtil.closeKeyboard(RoadModernUrbanTransitActivity.this);
            operationMode.setOnClickListener(view -> {
                RollUtil.alertBottomWheelOption(RoadModernUrbanTransitActivity.this, operationModeDict, operationMode.getSelectTextView(), new RollUtil.OnWheelViewClick() {
                    @Override
                    public void onClick(View view, int index) {
                        operationMode.setValue(operationModeDict.get(index));
                    }
                });
            });
            // 线路模式
            InputItem lineMode = convertView.findViewById(R.id.lineMode);
            lineMode.setOnClickListener(view -> {
                RollUtil.alertBottomWheelOption(RoadModernUrbanTransitActivity.this, lineModeDict, lineMode.getSelectTextView(), new RollUtil.OnWheelViewClick() {
                    @Override
                    public void onClick(View view, int index) {
                        lineMode.setValue(lineModeDict.get(index));
                    }
                });
            });
            // 车站形式
            InputItem stationForm = convertView.findViewById(R.id.stationForm);
            stationForm.setOnClickListener(view -> {
                RollUtil.alertBottomWheelOption(RoadModernUrbanTransitActivity.this, stationFormDict, stationForm.getSelectTextView(), new RollUtil.OnWheelViewClick() {
                    @Override
                    public void onClick(View view, int index) {
                        stationForm.setValue(stationFormDict.get(index));
                    }
                });
            });
        }

    }
}